package com.andy.process.abstracts;

import com.andy.common.entity.Configuration;
import com.andy.common.entity.Connect;
import com.andy.process.threadpool.Connector;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;

/**
 * Created by Administrator on 2017/9/5.
 */
public abstract class AbstractSource<T> {

    protected Connection getConnection(Configuration conf) {
        Connect connect = null;
        if (connect == null)
            connect = conf.getConnect();
        Properties prop = connect.getConfig();
        Connector connector = Connector.getInstance(prop);
        return connector.getConnection();
    }

    public abstract void insert() throws SQLException;

    public abstract List<T> getDataSource();
}
